package com.umanji.user.service;

import java.util.List;

import com.umanji.user.domain.Members;

import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.transaction.annotation.Transactional;

@PreAuthorize("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
public interface MemberService {

    @PostFilter("filterObject.email == principal.username or hasRole('ROLE_ADMIN')")
    @Transactional(value = "umanji", readOnly = true)
    List<Members> findAll();

    // @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional(value = "umanji", readOnly = false)
    void persist(Members entity);

    @PreFilter("filterObject.email == principal.username")
    @Transactional(value = "umanji", readOnly = false)
    void merge(Members entity);


    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional(value = "umanji", readOnly = false)
    void remove(Members entity);

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional(value = "umanji", readOnly = false)
    void mergedRemove(Members entity);

    @Transactional(value = "umanji", readOnly = true)
    Members find(Long id);

    @Transactional(value = "umanji", readOnly = true)
	Object findname(String userok);

    @Transactional(value = "umanji", readOnly = true)
	Object userfindId(String name, Integer jumin1, Integer jumin2);

    @Transactional(value = "umanji", readOnly = true)
	Object userfindPw(String name, Integer jumin1, Integer jumin2, String userid);

    @Transactional(value = "umanji", readOnly = true)
	Object userfindIdCount(String name, Integer jumin1, Integer jumin2);

    @Transactional(value = "umanji", readOnly = true)
	Object userfindPwCount(String name, Integer jumin1, Integer jumin2,
			String userid);
}
